#include <cstdint>
#include <cstdlib>
#include <iostream>
#include <istream>
#include <iterator>
#include <set>
#include <vector>
using ll = int64_t;
#define sl static inline
ll T,n,arr[10],ans;
std::set<ll >v;

sl void solve(){
    ans=0;
    std::cin>>n;
    v.clear();
    for(ll i=1;i<=n;i++){
        std::cin>>arr[i];
        v.emplace(arr[i]);
    }
    for(ll i=1;i<=n;i++){
        for(ll j=i+1;j<=n;j++){
            v.emplace(std::abs(arr[i]-arr[j]));
        }
    }
    for(auto a = v.begin();a!=v.end();a++){
        for(auto b=a;b!=v.end();b++){
            for(auto c=b;c!=v.end();c++){
                for(ll i=1;i<=n;i++){
                    if(!(arr[i]==*a || arr[i]==*b || arr[i]==*c || arr[i]==*a+*b||arr[i]==*a+*c||arr[i]==*b+*c||arr[i]==*a+*b+*c)){
                        goto nxt;
                    }
                }
                ans++;
                nxt:;
            }
        }
    }
    std::cout<<ans<<"\n";
}

int main(){
    std::iostream::sync_with_stdio(false);
    std::cin.tie(nullptr);

    std::cin>>T;
    while(T--){
        solve();
    }
}